// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT license

#include "stdafx.h"
#include "WorldBuilder.h"
#include "Pickable.h"
#include "View3d.h"
#include "Color.h"

Pickable::Pickable() 
{
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

bool Pickable::hasPickColor() const
{
    return m_pickColor != PickColor();
}

void Pickable::setPickColor(const PickColor & color)
{
    m_pickColor = color;
}

PickColor Pickable::getPickColor() const
{
    return m_pickColor;
}

void Pickable::clearPickColor()
{
    m_pickColor = PickColor();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

void Pickable::setColorIfNotPicking(View3d * view, 
                                    const Color & color) const
{
    if(!view->isDrawingInPickMode())
    {
        color();
    }
}

void Pickable::setColorOrPickCode(View3d * view, const Color & color,
                                  GLubyte pickCode) const
{
    if(view->isDrawingInPickMode())
    {
        PickColor pckCol = getPickColor();
        pckCol.setSecondaryComponent(pickCode);
        pckCol.setInRenderContext();
    }
    else
    {
        color();
    }
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

bool Pickable::isSelectable() const
{
    return false;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Create Python wrappers. This code be called once the Python manager
// has been properly initialized


